<script type="text/x-template" id='my-refer'>
    <div>
        <div class="weui-tab">
            <div class="weui-navbar">
                <div @click="tabname='haibao'" :class="tabname=='haibao'?'weui-bar__item_on':''" class="weui-navbar__item ">
                    邀请海报
                </div>
                <div @click="tabname='log'" :class="tabname=='log'?'weui-bar__item_on':''" class="weui-navbar__item">
                    奖励记录
                </div>
            </div>
            <div v-if="tabname=='haibao'" class="weui-tab__panel">
                <img :src="haibao" width="100%">
            </div>

            <div v-if="tabname=='log'" class="weui-tab__panel">
                <div class="weui-panel">
                    <!--   <div class="weui-panel__hd">文字列表附来源</div> -->
                    <template v-for="item in log.list">
                        <div class="weui-panel__bd">
                            <div class="weui-media-box weui-media-box_text">
                                <h4 class="weui-media-box__title">金额:{{item.num}}</h4>
                                <p class="weui-media-box__desc">
                                    来源:{{item.remark}}
                                </p>
                                <ul class="weui-media-box__info">
                                </ul> 
                            </div>
                        </div>
                    </template>
                    <div v-if="log.page>0" class="weui-panel__ft">
                        <a @click="getLog" href="javascript:void(0);" class="weui-cell weui-cell_access weui-cell_link">
                            <div class="weui-cell__bd">查看更多</div>
                            <span class="weui-cell__ft"></span>
                        </a>    
                    </div>
                </div>
            </div>

        </div>
    </div>
</script>
<script>
    var myRefer = Vue.component('my-refer', {
        template: '#my-refer',
        data: function (){
            return {
                tabname: 'haibao',
                log:{
                    page:1,
                    list:[]
                },
                haibao:''
            }
        },
        created: function () {
            this.getHaiBao();
            this.getLog();
        },
        methods:{
            getLog: function () {
                var self = this;
                http({
                    url: newBaseUrl + 'getreferlog&page='+self.log.page
                }).then(function(res){
                    res = res.data;
                    if(res.ret==0) {
                        for(var i=0;i<res.data.length;i++) {
                            self.log.list.push(res.data[i]);
                        }
                        self.log.page++;
                    }else{
                        self.log.page = 0;
                    }
                })
            },
            getHaiBao: function () {
                var self = this;
                http({
                    url: baseUrl + 'gethaibao',
                }).then(function(res){
                    res = res.data;
                    self.haibao = res.data;
                })
            }
        }
    })
</script>
